package com.cloud.adrian.novel.user.manager.feign;

import com.cloud.adrian.novel.book.dto.req.BookCommentReqDto;
import com.cloud.adrian.novel.book.feign.BookFeign;
import com.cloud.adrian.novel.common.auth.UserHolder;
import com.cloud.adrian.novel.common.resp.RestResp;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 小说微服务调用 feign 客户端管理
 * @Author: xiangguiliang
 * @version: 1.0
 * @since: 2024/05/18
 */
@Component
@AllArgsConstructor
public class BookFeignManager {
    private final BookFeign bookFeign;

    public RestResp<Void> publishComment(BookCommentReqDto dto) {
        dto.setUserId(UserHolder.getUserId());
        return bookFeign.publishComment(dto);
    }

    public RestResp<Void> updateComment(Long id, String content) {
        BookCommentReqDto dto = BookCommentReqDto.builder()
                .commentId(id)
                .commentContent(content)
                .userId(UserHolder.getUserId())
                .build();
        return bookFeign.updateComment(dto);
    }

    public RestResp<Void> deleteComment(Long id) {
        BookCommentReqDto dto = BookCommentReqDto.builder()
                .commentId(id).userId(UserHolder.getUserId()).build();
        return bookFeign.deleteComment(dto);
    }
}
